#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e5 + 5;

int n, n2;
struct Line {
  int h, x;
  int op;
  bool operator<(const Line& o) const { return x < o.x; }
} a[N << 1];
struct Point {
  int x, y;
};
void solve() {
  cin >> n;
  n2 = n * 2;
  rep(i, 1, n) {
    int h, l, r;
    cin >> h >> l >> r;
    a[i] = {h, l, 1};
    a[i + n] = {h, r, -1};
  }
  sort(a + 1, a + n2 + 1);
  vector<Point> ans;
  multiset<int> st;
  int pre = 0;
  int i = 1;
  while (i <= n2) {
    int x = a[i].x;
    while (a[i].x == x) {
      if (a[i].op == 1)
        st.insert(a[i].h);
      else
        st.erase(st.find(a[i].h));
      i++;
    }
    int now = st.empty() ? 0 : *st.rbegin();
    if (now != pre) {
      ans.push_back({x, pre});
      ans.push_back({x, now});
      pre = now;
    }
  }
  cout << ans.size() << endl;
  for (auto p : ans) cout << p.x << ' ' << p.y << endl;
  return;
}
int main() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}